/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package helpers;

import entities.Target;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author arnaldo
 */
public class RandomGenerator {

    public RandomGenerator() {
    }

    private void initNames() {
    }

    private void initCompanies() {
    }

    public static Target [] targets = new Target[50];

    public static void initTargets(){
        
        for(int i=0;i<50;i++){
            targets[i] = new Target();
            targets[i].setId(i+1);
            targets[i].setAge(RandomGenerator.Age());
            targets[i].setRace(RandomGenerator.Race());
            targets[i].setRadio(0);
            targets[i].setLocation(MyPolygon.randomPolygon());
        }
    }

    public static Target Target(){
        return targets[rand.nextInt(50)];
    }

    public static Random rand = new Random();
    public static String[] races = new String[]{
        "Caucasian",
        "African American/Black",
        "Hispanic/Latino",
        "Asian",
        "Middle eastern",
        "Pacific Islander",
        "Native American/Alaskan",
        "Other"
    };

    public static int randomInt(){
        return RandomGenerator.rand.nextInt();
    }

    public static String buildEmail(String login){
        return login + "@random.com";
    }

    public static String UserName() {
        String str = "";
        for (int i = 0; i < 10; i++) {
            str += (char) (rand.nextInt(25) + 97);
        }

        return str;
    }

    public static String CompanyName() {
        String str = "";
        for (int i = 0; i < 10; i++) {
            str += (char) (rand.nextInt(25) + 97);
        }

        return str;
    }

    public static String Password() {

        String str = "";

        for (int i = 0; i < 10; i++) {
            str += (char) (rand.nextInt(25) + 97);
        }

        MessageDigest m;
        try {
            m = MessageDigest.getInstance("MD5");
            m.update(str.getBytes(), 0, str.length());
            return (new BigInteger(1, m.digest()).toString(16));

        } catch (NoSuchAlgorithmException ex) {
            Logger.getLogger(RandomGenerator.class.getName()).log(Level.SEVERE, null, ex);
        }

        return "abc12345";
    }

    public static MyPoint Location() {

        double lat = (double) (rand.nextInt(43636813 - 30818223) + 30818223) / 1000000;
        double lon = -1 * (double) (rand.nextInt(95663983 - 77294843) + 77294843) / 1000000;
        MyPoint p = new MyPoint(lat, lon);

        return p;
    }

    public static int Race() {
        return rand.nextInt(8) + 1;
    }

    public static int Age() {
        return rand.nextInt(50) + 16;
    }

    public static int Answer(int max) {
        return rand.nextInt(max) + 1;
    }

    public static String[] Questions(int max) {
        String[] questions = new String[max];

        for (int i = 0; i < max; i++) {
            questions[i] = "Do you Question " + (i + 1) + ":";
        }

        return questions;
    }

}
